package com.moter.demo01.juc.alllocks.spinlock;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;

/**
 * 消费者
 */
public class MyConsumer implements Consumer<Products> {
    /**
     * 消费产品
     * @param products
     */
    @Override
    public void accept(Products products) {
        ArrayBlockingQueue<Products.Product> queue = products.getQueue();
        try {
            queue.poll(5, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
